﻿using System;
using System.Collections.Generic;
using System.Reflection;

namespace Hxsoft.AppV1.Module
{
	[Serializable]
	public enum CommentContentViewType
	{
		List
	}

	[Serializable]
	public class CommentContentConfiguration : ISpecialModuleContentPage
	{
		public string ContentPage { get; set; }
		public string InfoType { get; set; }
		public string InfoId { get; set; }
		public int? ListPageSize { get; set; }
		public int? ListContentCapacity { get; set; }
		public string ListType { get; set; }
		public string ListCssClass { get; set; }
		public Dictionary<string, string> ListParameters { get; set; }
	}

	[Serializable]
	public class CommentPageConfiguration : SpecialPageConfiguration
	{
		public bool? ShowHeader { get; set; }
		public bool? ShowMore { get; set; }
		public string ListTarget { get; set; }
		public int? LoadCount { get; set; }
		public int? ContentCapacity { get; set; }
		public string ListType { get; set; }
		public string CssClass { get; set; }
		public Dictionary<string, string> Parameters { get; set; }
	}




	public class CommentSpecialModule : ISpecialModule
	{
		private ISpecialModuleParser _parser;
		private ISpecialModuleParser Parser
		{
			get
			{
				if (_parser == null)
				{
					Assembly assembly = Assembly.Load("Hxsoft.AppV1.GenericWebUI");
					_parser = (ISpecialModuleParser)assembly.CreateInstance("Hxsoft.AppV1.WebUI.CommentSpecialModule");
				}

				return _parser;
			}
		}




		#region ISpecialModule 成员

		bool ISpecialModule.ExistsModule(int siteId, int specialId, string moduleCode)
		{
			return false;
		}

		string ISpecialModule.CreateModule(int siteId, int specialId, string moduleCode, string moduleName)
		{
			return "";
		}

		void ISpecialModule.UpdateModule(int siteId, int specialId, string refModuleId, string newName)
		{
			return;
		}

		void ISpecialModule.DeleteModule(int siteId, int specialId, string refModuleId)
		{
			return;
		}

		Guid? ISpecialModule.GetResourceId(int siteId, int specialId, string moduleCode, string refModuleId)
		{
			return null;
		}

		Resources.CodeId ISpecialModule.GetResourceCodeId(int siteId, int specialId, string moduleCode, string refModuleId)
		{
			return null;
		}

		#endregion

		#region ISpecialModule 成员

		private string moduleType = null;
		string ModuleType
		{
			get { return moduleType; }
			set { moduleType = value; }
		}

		string ISpecialModule.ModuleType
		{
			get { return ModuleType; }
			set { ModuleType = value; }
		}

		string ISpecialModule.GetAccreditUrlPattern(Special special)
		{
			return null;
		}

		string ISpecialModule.GetManageUrlPattern(Special special)
		{
			return null;
		}

		string ISpecialModule.GetContentConfigurationUrlPattern(Special special)
		{
			return SpecialModuleHelper.SpecialModuleConfigurations[ModuleType].ContentConfigurationUrl;
		}

		string ISpecialModule.GetPageConfigurationUrlPattern(Special special)
		{
			return SpecialModuleHelper.SpecialModuleConfigurations[ModuleType].PageConfigurationUrl;
		}

		#endregion

		#region ISpecialModule 成员


		string ISpecialModule.SerializeContentConfiguration(object config)
		{
			if (config == null) return null;
			return Serialization.SerializeJson(config);
		}

		object ISpecialModule.DeserializeContentConfiguration(string config)
		{
			if (string.IsNullOrEmpty(config)) return null;
			return Serialization.DeserializeJson<CommentContentConfiguration>(config);
		}

		string ISpecialModule.SerializePageConfiguration(SpecialPageConfiguration config)
		{
			if (config == null) return null;
			return Serialization.SerializeJson(config);
		}

		SpecialPageConfiguration ISpecialModule.DeserializePageConfiguration(string config)
		{
			if (string.IsNullOrEmpty(config)) return null;
			return Serialization.DeserializeJson<CommentPageConfiguration>(config);
		}

		#endregion

		#region ISpecialModuleParser 成员

		string ISpecialModuleParser.ParsePreviewPart(SpecialTemplateConfiguration templateConfiguration, SpecialModule module, SpecialPageConfiguration configuration, Special specialInfo, SpecialPage pageInfo, ref SpecialPageInfo page)
		{
			return Parser.ParsePreviewPart(templateConfiguration, module, configuration, specialInfo, pageInfo, ref page);
		}

		string ISpecialModuleParser.ParsePreviewContent(SpecialTemplateConfiguration templateConfiguration, SpecialModule module, Special specialInfo, SpecialPage pageInfo, ref SpecialPageInfo page, string moduleView)
		{
			return Parser.ParsePreviewContent(templateConfiguration, module, specialInfo, pageInfo, ref page, moduleView);
		}


		string ISpecialModuleParser.ParsePart(SpecialTemplateConfiguration templateConfiguration, SpecialModule module, SpecialPageConfiguration configuration, Special specialInfo, SpecialPage pageInfo, ref SpecialPageInfo page)
		{
			return Parser.ParsePart(templateConfiguration, module, configuration, specialInfo, pageInfo, ref page);
		}

		string ISpecialModuleParser.ParseContent(SpecialTemplateConfiguration templateConfiguration, SpecialModule module, Special specialInfo, SpecialPage pageInfo, ref SpecialPageInfo page)
		{
			return Parser.ParseContent(templateConfiguration, module, specialInfo, pageInfo, ref page);
		}

		#endregion
	}
}
